package cate.game.activity.herodirectbuy;

import cate.common.table.herodirectbuy.row.HeroDirectBuyPoolRow;
import cate.game.res.MixRes;
import cp.solution.util.str.Str;
import easy.java.dev.note.NoteField;

public class HeroRewardPool {
    @NoteField("折扣")
    public int discount;

    @NoteField("奖励")
    public String rewardStr;

    @NoteField("是否稀有")
    public boolean isRare;

    @NoteField("原价")
    public int priceOld;

    @NoteField("现价")
    public int priceNow;

    @NoteField("充值项ID")
    public int payId;

    @NoteField("是否已购买")
    public boolean purchase;

    public void changeToPool(HeroDirectBuyPoolRow row) {
        discount = row.discount;
        rewardStr = row.rewardStr;
        isRare = row.isRare;
        priceOld = changeToPrice(row.type, row.priceOld);
        priceNow = changeToPrice(row.type, row.priceNow);
        payId = row.payId;
    }

    private int changeToPrice(int type, String priceOld) {
        int price;
        if (type == HeroDirectBuyPoolRow.TYPE_ITEM) {
            MixRes costRes = new MixRes(priceOld);
            price = (int)costRes.items.get(0).num;
        } else {
            price = Str.toInteger(priceOld, 0) * 100;
        }
        return price;
    }


}
